<!doctype html>
<html lang="zh-CN" xml:lang="zh-CN">

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta charset="UTF-8" />
    <title>我的购物车-小麦商城</title>
    <meta name="viewport" content="width=1226" />
    <link rel="shortcut icon" href="__PUBLIC__/Home/images/logo.ico" type="image/x-icon" />
    <link rel="icon" href="__PUBLIC__/Home/images/logo.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__PUBLIC__/Home/css/base.min.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/cart.min.css" />
    <script src="__PUBLIC__/Admin/js/jquery.min.js"></script>
    <script src="__PUBLIC__/js/dialog/layer.js"></script>
    <script src="__PUBLIC__/js/dialog.js"></script>
    <script type="text/javascript">
        var _head_over_time = (new Date()).getTime();
    </script>
</head>

<body>
<div class="site-header site-mini-header">
    <div class="container">
        <div class="header-logo">
            <a class="logo ir" href="{:u('home/index/index')}" title="小麦官网">小麦官网</a>
        </div>
        <div class="header-title" id="J_miniHeaderTitle">
            <h2>我的购物车</h2><p>温馨提示：产品是否购买成功，以最终下单为准哦，请尽快结算</p>
        </div>

        <if condition="isset($user)">
            <div class="topbar-info" id="J_userInfo">
			<span class="user">
				<a rel="nofollow" class="user-name" href="{:u('home/user/index')}" target="_blank">
                    <span class="name">{$user['uname']}</span>
                </a>
				<ul class="user-menu">
                    <li><a class="home-user" rel="nofollow" href="{:u('home/user/index')}" target="_blank">个人中心</a></li>
                    <li><a class="home-user" rel="nofollow" href="{:u('home/user/loginOut')}">退出登录</a></li>
                </ul>
			</span>
                <script>
                    $(function(){
                        $(".user").hover(function(){
                            $(".user-name").css({'color':'#ff6700','background':'#fff'});
                            $(".user-menu").stop().slideDown();
                        },function(){
                            $(".user-name").css({'color':'#757575','background':'transparent'});
                            $(".user-menu").stop().slideUp();
                        });
                    })
                </script>
                <span class="sep">|</span>
                <a rel="nofollow" class="link link-order" href="{:u('home/user/order')}" target="_blank">我的订单</a>
            </div>
            <else />
        <div class="topbar-info" id="J_userInfo">
            <a rel="nofollow" class="link" href="{:U('home/user/login')}" data-needlogin="true">登录</a><span class="sep">|</span>
            <a rel="nofollow" class="link" href="{:U('home/user/register')}">注册</a>
        </div>
        </if>


    </div>
</div>

<div class="page-main">

    <div class="container">
        <if condition="!$cartData">
        <div class="cart-empty" id="J_cartEmpty">
            <h2>您的购物车还是空的！</h2>
            <p class="login-desc">登录后将显示您之前加入的商品</p>
            <a href="#" class="btn btn-primary btn-login" id="J_loginBtn">立即登录</a>
            <a href="{:u('home/list/index')}" class="btn btn-primary btn-shoping J_goShoping">马上去购物</a>
        </div>
        </if>
        <if condition="$cartData">

        <div id="J_cartBox" class="">
            <div class="cart-goods-list">
                <div class="list-head clearfix">
                    <div class="col col-check"><i class="iconfont icon-checkbox icon-checkbox-selected" id="J_selectAll">&#x221a;</i>全选</div>
                    <div class="col col-img">&nbsp;</div>
                    <div class="col col-name">商品名称</div>
                    <div class="col col-price">单价</div>
                    <div class="col col-num">数量</div>
                    <div class="col col-total">小计</div>
                    <div class="col col-action">操作</div>
                </div>
                <div class="list-body" id="J_cartListBody">
                    <foreach name="cartData['goods']" item="v" key="k">
                    <div mid="111" class="item-box">
                        <div class="item-table J_cartGoods" data-info="{ commodity_id:'1160700019', gettype:'buy', itemid:'2160700016_0_buy', num:'1'} ">
                            <div class="item-row clearfix">
                                <div class="col col-check">
                                    <i good-key="{$k}" class="iconfont icon-checkbox icon-checkbox-selected J_itemCheckbox" data-status="1">√</i>
                                </div>
                                <div class="col col-img">
                                    <a href="" target="_blank">
                                        <img alt="" src="__ROOT__/{$v['good']['glist']}" width="80" height="80">
                                    </a>
                                </div>
                                <div class="col col-name">
                                    <div class="tags">
                                    </div>
                                    <h3 class="name">
                                        <a href="" target="_blank">{$v['info']}</a>
                                    </h3>
                                    <p class="desc"> <span>适配机型：</span>{$v['name']}</p>
                                </div>
                                <div class="col col-price">{$v['price']} 元</div>
                                <div class="col col-num">
                                    <div class="change-goods-num clearfix J_changeGoodsNum">
                                        <a good-key="{$k}" href="javascript:void(0)" class="J_minus"><i class="iconfont"></i></a>
                                        <input tyep="text" value="{$v['num']}" class="goods-num J_goodsNum">
                                        <a good-key="{$k}" href="javascript:void(0)" class="J_plus"><i class="iconfont"></i></a>
                                    </div>
                                </div>
                                <div class="col col-total"> <span>{$v['total']}</span>元
                                    <p class="pre-info"> </p>
                                </div>
                                <div class="col col-action">
                                    <a good-num="{$v['num']}" good-total="{$v['total']}" good-key="{$k}" href="javascript:void(0);" title="删除" class="del J_delGoods"><i class="iconfont"></i></a>
                                </div>
                            </div>
                        </div>
                    </div>
                    </foreach>
                    <script>
                        $(function(){
                            // 商品减少
                            $(".J_minus").click(function(){
                                var n = $(this).siblings("input").val();
                                if(n <= 1){
                                    dialog.error("商品数量最少为1");
                                    return false;
                                }
                                n--;
                                changeNum(this,n);
                            });
                            // 商品添加
                            $(".J_plus").click(function(){
                                var n = $(this).siblings("input").val();
                                n++;
                                changeNum(this,n);
                            });
                            // 改变当前商品数量和商品总数
                            function changeNum(obj,n){
                                var goodKey = $(obj).attr("good-key");
                                $.post("{:u('home/cart/changeNums')}",{goodKey:goodKey,num:n},function(res){
                                    if($(obj).parents(".col-num").siblings(".col-check").find(".J_itemCheckbox").is(".icon-checkbox-selected")){
                                        $("#J_cartTotalPrice").text(res.total);
                                    }
                                    $(obj).parents(".col-num").siblings(".col-total").find("span").text(res.goodData.total);
                                },'json');
                                $(obj).siblings("input").val(n);
                            }
                            // 商品选择按钮
                            $(".J_itemCheckbox").click(function(){
                                $(this).toggleClass("icon-checkbox-selected");
                                var goodNum = $(this).parent().siblings(".col-total").find("span").text();
                                var totalPrice = $("#J_cartTotalPrice").text();
                                // 进行订单总价的加减
                                if($(this).is(".icon-checkbox-selected")){
                                    $("#J_cartTotalPrice").text(parseInt(totalPrice) + parseInt(goodNum));
                                }else{
                                    $("#J_cartTotalPrice").text(totalPrice - goodNum);
                                }
                                $("#J_selTotalNum").text($(".icon-checkbox-selected.J_itemCheckbox").length);
                                // 判断是否全选
                                if($(".icon-checkbox-selected.J_itemCheckbox").length == $("#J_cartTotalNum").text()){
                                    $("#J_selectAll").addClass("icon-checkbox-selected");
                                    $("#J_goCheckout").attr("class","btn btn-a btn btn-primary");
                                }else{
                                    $("#J_selectAll").removeClass("icon-checkbox-selected");
                                    // 判断是否可以结算
                                    if($(".icon-checkbox-selected.J_itemCheckbox").length == 0){
                                        $("#J_goCheckout").attr("class","btn btn-a btn btn-disabled");
                                    }else{
                                        $("#J_goCheckout").attr("class","btn btn-a btn btn-primary");
                                    }
                                }
                            });
                            // 商品全选按钮
                            $("#J_selectAll").click(function(){
                                $(this).toggleClass("icon-checkbox-selected");
                                if($(this).is(".icon-checkbox-selected")){
                                    $(".J_itemCheckbox").addClass("icon-checkbox-selected");
                                    // 取得购物车所有商品总价
                                    var totalPrice = 0;
                                    $(".item-row .col-total span").each(function(){
                                        totalPrice += parseInt($(this).text());
                                    });
                                    $("#J_cartTotalPrice").text(totalPrice);
                                    $("#J_goCheckout").attr("class","btn btn-a btn btn-primary");
                                }else{
                                    $(".J_itemCheckbox").removeClass("icon-checkbox-selected");
                                    $("#J_cartTotalPrice").text(0);
                                    $("#J_goCheckout").attr("class","btn btn-a btn btn-disabled");
                                }
                                $("#J_selTotalNum").text($(".icon-checkbox-selected.J_itemCheckbox").length);
                            });
                            // 删除商品
                            $(".J_delGoods").click(function(e){
                                var _this = $(this);
                                layer.confirm('确认删除？', {
                                    btn: ['确定','取消']
                                }, function(){
                                    var goodKey = _this.attr("good-key");
                                    var goodTotal = _this.attr("good-total");
                                    var goodNum = _this.attr("good-num");
                                    $.post("{:u('home/cart/delCart')}",{'goodKey':goodKey,'goodTotal':goodTotal,'goodNum':goodNum},function(res){
                                        //console.log(res);return false;
                                        _this.parents(".item-box").remove();
                                        var totalPrice = 0;
                                        $(".icon-checkbox-selected.J_itemCheckbox").parent().siblings(".col-total").find("span").each(function(){
                                            totalPrice += parseInt($(this).text());
                                        });
                                        $("#J_cartTotalPrice").text(totalPrice);
                                        $("#J_cartTotalNum").text(res.len);
                                        $("#J_selTotalNum").text($(".icon-checkbox-selected.J_itemCheckbox").length);
                                        layer.msg('删除成功', {icon: 1});
                                    },'json');
                                });
                            });
                        })
                    </script>
                </div>
            </div>
            <div class="raise-buy-box" id="J_raiseBuyBox"> </div>
            <div class="cart-bar clearfix" id="J_cartBar">
                <div class="section-left">
                    <a href="{:u('home/list/index')}" class="back-shopping J_goShoping">继续购物</a>
                    <span class="cart-total">共 <i id="J_cartTotalNum"><?php echo count($cartData['goods']); ?></i> 件商品，已选择 <i id="J_selTotalNum"><script>document.write($('.icon-checkbox-selected.J_itemCheckbox').length);</script></i> 件</span>
							<span class="cart-coudan hide" id="J_coudanTip">
                        ，还需 <i id="J_postFreeBalance"></i> 元即可免邮费  <a href="javascript:void(0);" id="J_showCoudan">立即凑单</a>
                    </span>
                </div>
						<span class="activity-money hide">
                    活动优惠：减 <i id="J_cartActivityMoney">0</i> 元
                </span>
						<span class="total-price">
                    合计（不含运费）：<em id="J_cartTotalPrice">{$cartData['total']}</em>元
                </span>
                <a href="javascript:void(0);" class="btn btn-a btn btn-primary" id="J_goCheckout">去结算</a>
                <script>
                    // 跳到订单页结算
                    $(function(){
                        $("#J_goCheckout").click(function(){
                            if($(this).is(".btn.btn-a.btn-primary")){
                                var goodKey = '';
                                $(".icon-checkbox-selected.J_itemCheckbox").each(function(){
                                    goodKey += $(this).attr("good-key") + ',';
                                });
                                $.post("{:u('home/order/getGoods')}",{'goodKey':goodKey},function(res){
                                    if(res.volid){
                                        location.href = "{:u('home/order/index')}";
                                    }
                                },'json');
                            }
                        });
                    })
                </script>
                <div class="no-select-tip hide" id="J_noSelectTip">
                    请勾选需要结算的商品
                    <i class="arrow arrow-a"></i>
                    <i class="arrow arrow-b"></i>
                </div>
            </div>
            <script>
                // 底部结算div跟随滚动条移动
                $(window).scroll(function(){
                    document.title = $(window).height() + '|' + $(window).scrollTop() + '|' + $("#J_raiseBuyBox").offset().top;
                    var height1 = parseInt($(window).height());
                    var height2 = parseInt($(window).scrollTop());
                    var height3 =parseInt($("#J_raiseBuyBox").offset().top);
                    if((height1 + height2) < height3){
                        if(!$("#J_cartBar").is(".cart-bar-fixed")){
                            $("#J_cartBar").addClass("cart-bar-fixed");
                        }
                    }else{
                        if($("#J_cartBar").is(".cart-bar-fixed")){
                            $("#J_cartBar").removeClass("cart-bar-fixed");
                        }
                    }
                });
            </script>
        </div>
        </if>
        <script>
        </script>

        <div class="cart-recommend hide" id="J_historyRecommend"></div>
        <div class="cart-recommend hide" id="J_miRecommendBox"></div>

        <div class="cart-recommend" id="J_miHistoryBox"></div>
    </div>
</div>

<div class="site-footer">
    <div class="container">
        <div class="footer-service">
            <ul class="list-service clearfix">
                <li>
                    <a rel="nofollow" href="//www.mi.com/static/fast/" target="_blank"><i class="iconfont">&#xe634;</i>预约维修服务</a>
                </li>
                <li>
                    <a rel="nofollow" href="//www.mi.com/service/exchange#back" target="_blank"><i class="iconfont">&#xe635;</i>7天无理由退货</a>
                </li>
                <li>
                    <a rel="nofollow" href="//www.mi.com/service/exchange#free" target="_blank"><i class="iconfont">&#xe636;</i>15天免费换货</a>
                </li>
                <li>
                    <a rel="nofollow" href="//www.mi.com/service/exchange#mail" target="_blank"><i class="iconfont">&#xe638;</i>满150元包邮</a>
                </li>
                <li>
                    <a rel="nofollow" href="//www.mi.com/static/maintainlocation/" target="_blank"><i class="iconfont">&#xe637;</i>520余家售后网点</a>
                </li>
            </ul>
        </div>
        <div class="footer-links clearfix">

            <dl class="col-links col-links-first">
                <dt>帮助中心</dt>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/service/account/register/" target="_blank">账户管理</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/service/buy/buytime/" target="_blank">购物指南</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/service/order/sendprogress/" target="_blank">订单操作</a>
                </dd>

            </dl>

            <dl class="col-links ">
                <dt>服务支持</dt>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/service/exchange" target="_blank">售后政策</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="http://fuwu.mi.com/" target="_blank">自助服务</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="http://xiazai.mi.com/" target="_blank">相关下载</a>
                </dd>

            </dl>

            <dl class="col-links ">
                <dt>线下门店</dt>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/c/xiaomizhijia/" target="_blank">小麦之家</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/static/maintainlocation/" target="_blank">服务网点</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/static/familyLocation/" target="_blank">零售网点</a>
                </dd>

            </dl>

            <dl class="col-links ">
                <dt>关于小麦</dt>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/about" target="_blank">了解小麦</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="http://hr.xiaomi.com/" target="_blank">加入小麦</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/about/contact" target="_blank">联系我们</a>
                </dd>

            </dl>

            <dl class="col-links ">
                <dt>关注我们</dt>

                <dd>
                    <a rel="nofollow" href="http://weibo.com/xiaomishangcheng" target="_blank">新浪微博</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="http://xiaoqu.qq.com/mobile/share/index.html?url=http%3A%2F%2Fxiaoqu.qq.com%2Fmobile%2Fbarindex.html%3Fwebview%3D1%26type%3D%26source%3Dindex%26_lv%3D25741%26sid%3D%26_wv%3D5123%26_bid%3D128%26%23bid%3D10525%26from%3Dwechat" target="_blank">小麦部落</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="#J_modalWeixin" data-toggle="modal">官方微信</a>
                </dd>

            </dl>

            <dl class="col-links ">
                <dt>特色服务</dt>

                <dd>
                    <a rel="nofollow" href="//order.mi.com/queue/f2code" target="_blank">F 码通道</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="//www.mi.com/giftcode/" target="_blank">礼物码</a>
                </dd>

                <dd>
                    <a rel="nofollow" href="//order.mi.com/misc/checkitem" target="_blank">防伪查询</a>
                </dd>

            </dl>

            <div class="col-contact">
                <p class="phone">400-100-5678</p>
                <p>
							<span class="J_serviceTime-normal" style="
">周一至周日 8:00-18:00</span>
                    <span class="J_serviceTime-holiday" style="display:none;">1月27日至2月2日服务时间 9:00-18:00</span><br>（仅收市话费）</p>
                <a rel="nofollow" class="btn btn-line-primary btn-small" href="//www.mi.com/service/contact" target="_blank"><i class="iconfont">&#xe600;</i> 24小时在线客服</a>
            </div>
        </div>
    </div>
</div>
<div class="site-info">
    <div class="container">
        <div class="logo ir">小麦官网</div>
        <div class="info-text">
            <p class="sites">
                <a rel="nofollow" href="//www.mi.com/index.html" target="_blank">小麦商城</a><span class="sep">|</span>
                <a rel="nofollow" href="http://www.miui.com/" target="_blank">MIUI</a><span class="sep">|</span>
                <a rel="nofollow" href="http://www.miliao.com/" target="_blank">米聊</a><span class="sep">|</span>
                <a rel="nofollow" href="http://www.duokan.com/" target="_blank">多看书城</a><span class="sep">|</span>
                <a rel="nofollow" href="http://www.miwifi.com/" target="_blank">小麦路由器</a><span class="sep">|</span>
                <a rel="nofollow" href="http://call.mi.com/" target="_blank">视频电话</a><span class="sep">|</span>
                <a rel="nofollow" href="http://tuan.qiye.mi.com/" target="_blank">企业团购</a><span class="sep">|</span>
                <a rel="nofollow" href="http://xiaomi.tmall.com/" target="_blank">小麦天猫店</a><span class="sep">|</span>
                <a rel="nofollow" href="http://shop115048570.taobao.com" target="_blank">小麦淘宝直营店</a><span class="sep">|</span>
                <a rel="nofollow" href="http://union.mi.com/" target="_blank">小麦网盟</a><span class="sep">|</span>
                <a rel="nofollow" href="//www.mi.com/mimobile/" target="_blank">小麦移动</a><span class="sep">|</span>
                <a rel="nofollow" href="#J_modal-globalSites" data-toggle="modal">Select Region</a>
            </p>
            <p>&copy;
                <a href="//www.mi.com/" target="_blank" title="mi.com">mi.com</a> 京ICP证110507号
                <a href="http://www.miitbeian.gov.cn/" target="_blank" rel="nofollow">京ICP备10046444号</a>
                <a rel="nofollow" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11010802020134" target="_blank">京公网安备11010802020134号 </a>
                <a rel="nofollow" href="//c1.mifile.cn/f/i/2013/cn/jingwangwen.jpg" target="_blank" rel="nofollow">京网文[2014]0059-0009号</a>

                <br> 违法和不良信息举报电话：185-0130-1238，本网站所列数据，除特殊说明，所有数据均出自我司实验室测试</p>
        </div>
        <div class="info-links">
            <a rel="nofollow" href="//privacy.truste.com/privacy-seal/validation?rid=4fc28a8c-6822-4980-9c4b-9fdc69b94eb8&lang=zh-cn" target="_blank"><img rel="nofollow" src="//c1.mifile.cn/f/i/17/site/truste.png" alt="TRUSTe Privacy Certification" /></a>
            <a rel="nofollow" href="//search.szfw.org/cert/l/CX20120926001783002010" target="_blank"><img rel="nofollow" src="//s01.mifile.cn/i/v-logo-2.png" alt="诚信网站" /></a>
            <a rel="nofollow" href="https://ss.knet.cn/verifyseal.dll?sn=e12033011010015771301369&ct=df&pa=461082" target="_blank"><img rel="nofollow" src="//s01.mifile.cn/i/v-logo-1.png" alt="可信网站" /></a>
            <a rel="nofollow" href="http://www.315online.com.cn/member/315140007.html" target="_blank"><img rel="nofollow" src="//s01.mifile.cn/i/v-logo-3.png" alt="网上交易保障中心" /></a>
        </div>
    </div>
    <div class="slogan ir">探索黑科技，小麦为发烧而生</div>
</div>
<script src="__PUBLIC__/Home/js/base.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Home/js/cart.min.js"></script>
<script src="__PUBLIC__/Home/js/xmsg_ti.js"></script>
</body>

</html>